import hljs from 'highlight.js'; import { IconContext } from 'react-icons'; import { FcFile, FcFolder } from 'react-icons/fc'; import ReactMarkdown from 'react-markdown'; import gfm from 'remark-gfm'; function isNotMaster(pathArray) { if (pathArray.length > 1) { if (pathArray[1] !== 'master') { return true; } else return false; } else return false; } function getSubArray(pathArray, acc) { if (acc.length === 0) { if (isNotMaster(pathArray)) { return pathArray.slice(0, 2); } else return pathArray.slice(0, acc.length + 1); } else return pathArray.slice(0, acc.length + 1); } async function getServerSideProps(context) { const res = await fetch('http://localhost:3000/api' + context.resolvedUrl); const data = await res.json(); return { props: { data } }; } function MidSection(props) { return (
{props.children}
); } function MainContentContainer(props) { return (
{props.children}
); } function BreadCrumbTrail(props) { const pathArray = props.pathArray; const recursion = (acc) => { if (acc.length === pathArray.length) { return acc; } else { const subArray = getSubArray(pathArray, acc); const breadCrumb = { name: pathArray[acc.length], href: '/' + subArray.join('/'), }; const newAcc = acc.concat([breadCrumb]); return recursion(newAcc); } }; const breadCrumbs = recursion([]); // remove commit breadCrumbs.splice(1, 1); return (
{breadCrumbs.map((breadCrumb) => ( / {breadCrumb.name} ))}
); } function DirectoryListing(props) { const parentPath = props.resultPath.length === 1 ? [props.resultPath[0], 'master'] : props.resultPath; const parentURL = '/' + parentPath.join('/') + '/' return ( ); } function CommitListing(props) { const subArray = props.resultContent.slice(1); return ( ); } function LineNos(props) { const count = props.textBlob.split('\n').length; const lineNos = [...Array(count).keys()].map((x) => x + 1).join('\n'); return (
      {lineNos}
    
); } function CodeBlock(props) { const highlightedHTML = hljs.highlightAuto(props.textBlob).value; return (
      
    
); } function TextDisplayGrid(props) { return (
); } function PageSubstance({ data }) { switch (data.resultType) { case 'rootDirectory': return (
{data.resultContent.readmeExists &&
} {data.resultContent.readmeExists && }
); break; case 'nonRootDirectory': return (
); break; case 'textBlob': return (
); break; case 'binaryBlob': return (

Binary content cannot be displayed.

); break; case 'commits': return (
); break; case 'error': return (

Error:

{data.resultContent}
); break; default: return (

Error:

Backend error: result type not recognised.

); } } function Main({ data }) { return (
); } export { getServerSideProps }; export default Main;